(function(c,b,a,d){c.fn.kkstarratings=function(e){c.fn.kkstarratings.options=c.extend({ajaxurl:null,nonce:null,func:null,grs:false,msg:"Rate this post",fuelspeed:400,thankyou:"Thank you for rating.",error_msg:"An error occured.",tooltip:true,tooltips:{0:{tip:"Poor",color:"red"},1:{tip:"Fair",color:"brown"},2:{tip:"Average",color:"orange"},3:{tip:"Good",color:"blue"},4:{tip:"Excellent",color:"green"}}},c.fn.kkstarratings.options,e?e:{});var f=[];this.each(function(){f.push(c(this))});c.fn.kkstarratings.fetch(f,0,"0%",c.fn.kkstarratings.options.msg,true);return this.each(function(){})};c.fn.kkstarratings.animate=function(g){if(!g.hasClass("disabled")){var f=c(".kksr-legend",g).html(),e=c(".kksr-fuel",g).css("width");c(".kksr-stars a",g).hover(function(){var h=c(this).attr("href").split("#")[1];if(c.fn.kkstarratings.options.tooltip!=0){if(c.fn.kkstarratings.options.tooltips[h-1]!=null){c(".kksr-legend",g).html(''+c.fn.kkstarratings.options.tooltips[h-1].tip+"")}else{c(".kksr-legend",g).html(f)}}c(".kksr-fuel",g).stop(true,true).css("width","0%");c(".kksr-stars a",g).each(function(j,k){var i=c(this),l=i.attr("href").split("#")[1];if(parseInt(l)<=parseInt(h)){c(".kksr-stars a",g).stop(true,true);i.hide().addClass("kksr-star").addClass("orange").fadeIn("fast")}})},function(){c(".kksr-stars a",g).removeClass("kksr-star").removeClass("orange");if(c.fn.kkstarratings.options.tooltip!=0){c(".kksr-legend",g).html(f)}c(".kksr-fuel",g).stop(true,true).animate({width:e},c.fn.kkstarratings.options.fuelspeed)}).unbind("click").click(function(){return c.fn.kkstarratings.click(g,c(this).attr("href").split("#")[1])})}else{c(".kksr-stars a",g).unbind("click").click(function(){return false})}};c.fn.kkstarratings.update=function(h,e,g,f,i){if(f=="true"){c(".kksr-fuel",h).removeClass("yellow").addClass("orange")}c(".kksr-fuel",h).stop(true,true).animate({width:e},c.fn.kkstarratings.options.fuelspeed,"linear",function(){if(f=="true"){h.addClass("disabled");c(".kksr-stars a",h).unbind("hover")}if(!c.fn.kkstarratings.options.grs||!i){c(".kksr-legend",h).stop(true,true).hide().html(g?g:c.fn.kkstarratings.options.msg).fadeIn("slow",function(){c.fn.kkstarratings.animate(h)})}else{c.fn.kkstarratings.animate(h)}})};c.fn.kkstarratings.click=function(h,e){c(".kksr-stars a",h).unbind("hover").unbind("click").removeClass("kksr-star").removeClass("orange").click(function(){return false});var g=c(".kksr-legend",h).html(),f=c(".kksr-fuel",h).css("width");c.fn.kkstarratings.fetch(h,e,f,g,false);return false};c.fn.kkstarratings.fetch=function(g,e,i,h,j){var f=[];c.each(g,function(){f.push(c(this).attr("data-id"))});c.ajax({url:c.fn.kkstarratings.options.ajaxurl,data:"action="+c.fn.kkstarratings.options.func+"&id="+f+"&stars="+e+"&_wpnonce="+c.fn.kkstarratings.options.nonce,type:"post",dataType:"json",beforeSend:function(){c(".kksr-fuel",g).animate({width:"0%"},c.fn.kkstarratings.options.fuelspeed);if(e){c(".kksr-legend",g).fadeOut("fast",function(){c(".kksr-legend",g).html(''+c.fn.kkstarratings.options.thankyou+"")}).fadeIn("slow")}},success:function(k){c.each(g,function(){var m=c(this),l=m.attr("data-id");if(k[l].success){c.fn.kkstarratings.update(m,k[l].fuel+"%",k[l].legend,k[l].disable,j)}else{c.fn.kkstarratings.update(m,i,h,false,j)}})},complete:function(){},error:function(k){c(".kksr-legend",g).fadeOut("fast",function(){c(".kksr-legend",g).html(''+c.fn.kkstarratings.options.error_msg+"")}).fadeIn("slow",function(){c.fn.kkstarratings.update(g,i,h,false,j)})}})};c.fn.kkstarratings.options={ajaxurl:bhittani_plugin_kksr_js.ajaxurl,func:bhittani_plugin_kksr_js.func,nonce:bhittani_plugin_kksr_js.nonce,grs:bhittani_plugin_kksr_js.grs,tooltip:bhittani_plugin_kksr_js.tooltip,tooltips:bhittani_plugin_kksr_js.tooltips,msg:bhittani_plugin_kksr_js.msg,fuelspeed:bhittani_plugin_kksr_js.fuelspeed,thankyou:bhittani_plugin_kksr_js.thankyou,error_msg:bhittani_plugin_kksr_js.error_msg}})(jQuery,window,document);jQuery(document).ready(function(a){a(".kk-star-ratings").kkstarratings()}); var woodiscuzValidator=(function($){ var message, tests, checkField, validate, mark, unmark, field, minmax, defaults, validateWords, lengthRange, lengthLimit, pattern, alertTxt, data, email_illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/, email_filter=/^.+@.+\..{2,50}$/; message={ invalid: 'invalid input', empty: 'please put something here', min: 'input is too short', max: 'input is too long', number_min: 'too low', number_max: 'too high', url: 'invalid URL', number: 'not a number', email: 'email address is invalid', email_repeat: 'emails do not match', password_repeat: 'passwords do not match', repeat: 'no match', complete: 'input is not complete', select: 'Please select an option' }; if(!window.console){ console={}; console.log=console.warn=function(){ return; }} defaults={alerts: true}; tests={ sameAsPlaceholder: function(a){ return $.fn.placeholder&&a.attr('placeholder')!==undefined&&data.val==a.prop('placeholder'); }, hasValue: function(a){ if(!a){ alertTxt=message.empty; return false; } return true; }, linked: function(a, b){ if(b!=a){ alertTxt=message[data.type + '_repeat']||message.no_match; return false; } return true; }, email: function(a){ if(!email_filter.test(a)||a.match(email_illegalChars)){ alertTxt=a ? message.email:message.empty; return false; } return true; }, text: function(a){ if(validateWords){ var words=a.split(' '); var wordsLength=function(len){ for (var w=words.length; w--;) if(words[w].length < len) return false; return true; }; if(words.length < validateWords||!wordsLength(2)){ alertTxt=message.complete; return false; } return true; } if(lengthRange&&a.length < lengthRange[0]){ alertTxt=message.min; return false; } if(lengthRange&&lengthRange[1]&&a.length > lengthRange[1]){ alertTxt=message.max; return false; } if(lengthLimit&&lengthLimit.length){ var obeyLimit=false; while (lengthLimit.length){ if(lengthLimit.pop()==a.length) obeyLimit=true; } if(!obeyLimit){ alertTxt=message.complete; return false; }} if(pattern){ var regex, jsRegex; switch (pattern){ case 'alphanumeric' : regex=/^[a-z0-9]+$/i; break; case 'numeric' : regex=/^[0-9]+$/i; break; case 'phone' : regex=/^\+?([0-9]|[-|' '])+$/i; break; default : regex=pattern; } try { jsRegex=new RegExp(regex).test(a); if(a&&!jsRegex) return false; } catch (err){ console.log(err, field, 'regex is invalid'); return false; }} return true; }, number: function(a){ if(isNaN(parseFloat(a))&&!isFinite(a)){ alertTxt=message.number; return false; } else if(lengthRange&&a.length < lengthRange[0]){ alertTxt=message.min; return false; } else if(lengthRange&&lengthRange[1]&&a.length > lengthRange[1]){ alertTxt=message.max; return false; } else if(minmax[0]&&(a | 0) < minmax[0]){ alertTxt=message.number_min; return false; } else if(minmax[1]&&(a | 0) > minmax[1]){ alertTxt=message.number_max; return false; } return true; }, date: function(a){ var day, A=a.split(/[-./]/g), i; if(field[0].valueAsNumber) return true; for (i=A.length; i--;){ if(isNaN(parseFloat(a))&&!isFinite(a)) return false; } try { day=new Date(A[2], A[1] - 1, A[0]); if(day.getMonth() + 1==A[1]&&day.getDate()==A[0]) return day; return false; } catch (er){ console.log('date test: ', err); return false; }}, url: function(a){ function testUrl(url){ return /^(https?:\/\/)?([\w\d\-_]+\.+[A-Za-z]{2,})+\/?/.test(url); } if(!testUrl(a)){ console.log(a); alertTxt=a ? message.url:message.empty; return false; } return true; }, hidden: function(a){ if(lengthRange&&a.length < lengthRange[0]){ alertTxt=message.min; return false; } if(pattern){ var regex; if(pattern=='alphanumeric'){ regex=/^[a-z0-9]+$/i; if(!regex.test(a)){ return false; }} } return true; }, select: function(a){ if(!tests.hasValue(a)){ alertTxt=message.select; return false; } return true; }}; mark=function(field, text){ if(!text||!field||!field.length) return false; var item=field.parents('.woodiscuz-item'), warning; if(item.hasClass('bad')){ if(defaults.alerts) item.find('.alert').html(text); } else if(defaults.alerts){ warning=$('
').html(text); item.append(warning); } item.removeClass('bad'); setTimeout(function(){ item.addClass('bad'); }, 0); }; unmark=function(field){ if(!field||!field.length){ console.warn('no "field" argument, null or DOM object not found'); return false; } field.parents('.woodiscuz-item') .removeClass('bad') .find('.alert').remove(); }; function testByType(type, value){ if(type=='tel') pattern=pattern||'phone'; if(!type||type=='password'||type=='tel') type='text'; return tests[type](value); } function prepareFieldData(el){ field=$(el); field.data('valid', true); field.data('type', field.attr('type')); pattern=field.attr('pattern'); } function keypress(e){ prepareFieldData(this); if(e.charCode) return testByType(this.type, String.fromCharCode(e.charCode)); } function checkField(){ if(this.type!='hidden'&&$(this).is(':hidden')) return true; prepareFieldData(this); field.data('val', field[0].value.replace(/^\s+|\s+$/g, "")); data=field.data(); alertTxt=message[field.prop('name')]||message.invalid; if(field[0].nodeName.toLowerCase()==="select"){ data.type='select'; } if(field[0].nodeName.toLowerCase()==="textarea"){ data.type='text'; } validateWords=data['validateWords']||0; lengthRange=data['validateLengthRange'] ? (data['validateLengthRange'] + '').split(','):[1]; lengthLimit=data['validateLength'] ? (data['validateLength'] + '').split(','):false; minmax=data['validateMinmax'] ? (data['validateMinmax'] + '').split(','):''; data.valid=tests.hasValue(data.val); if(data.valid){ if(tests.sameAsPlaceholder(field)){ alertTxt=message.empty; data.valid=false; } if(data.validateLinked){ var linkedTo=data['validateLinked'].indexOf('#')==0 ? $(data['validateLinked']):$(':input[name=' + data['validateLinked'] + ']'); data.valid=tests.linked(data.val, linkedTo.val()); } else if(data.valid||data.type=='select') data.valid=testByType(data.type, data.val); if(field.hasClass('optional')&&!data.val) data.valid=true; } if(data.valid) unmark(field); else { mark(field, alertTxt); submit=false; } return data.valid; } function checkAll($form){ $form=$($form); if($form.length==0){ console.warn('element not found'); return false; } var that=this, submit=true, fieldsToCheck=$form.find(':input').filter('[required=required], .required, .optional').not('[disabled=disabled]'); fieldsToCheck.each(function(){ submit=submit * checkField.apply(this); }); return !!submit; } return { defaults: defaults, checkField: checkField, keypress: keypress, checkAll: checkAll, mark: mark, unmark: unmark, message: message, tests: tests }})(jQuery); jQuery(document).ready(function ($){ var wpc_home_url=$('#wpc_home_url').val(); var wpc_plugin_dir_url=$('#wpc_plugin_dir_url').val(); var wpc_name; var wpc_email; var wpc_comment; var wpc_captcha; var wpc_comment_post_ID; var wpc_comment_parent; var wpc_form; var wpc_submitID; var wpc_comments_offset; var wpc_new_comment_id; var wpc_loading_image; var wpc_comment_text_before_editting; $(".wpc_comment").autoGrow(); $(document).on('click', '#wpc_openModalFormAction', function (){ $('#wpc_openModalFormAction').css('opacity', '0'); $('#wpc_openModalFormAction').css('pointer-events', 'none'); }); $(document).on('click', '#wpc_openModalFormAction .close', function (){ $('#wpc_openModalFormAction').css('opacity', '0'); $('#wpc_openModalFormAction').css('pointer-events', 'none'); }); wpc_loading_image=""; wpc_comments_offset=$('#wpc_comments_offset'); wpc_comments_offset.val('1'); $(document).on('focus', '.wpc_comment', function (){ var uniqueID=getUniqueID($(this)); $('#wpc-form-footer-' + uniqueID).slideDown(700); }); $(document).on('click', '.wpc-reply-link', function (){ var uniqueID=getUniqueID($(this)); $('#wpc-secondary-forms-wrapper-' + uniqueID).slideToggle(700); }); $(document).on('click', '.wpc-share-link', function (){ var uniqueID=getUniqueID($(this)); $('#share_buttons_box-' + uniqueID).slideToggle(1000); }); $(document).on('click', '.wpc_captcha_refresh_img', function (){ var uniqueID=getUniqueID($(this)); var wpc_commpost_ID=$('#wpc_comment_post_ID-' + uniqueID).val(); var wpc_commparent=$('#wpc_comment_parent-' + uniqueID).val(); $("#wpc_captcha_img-" + uniqueID).attr("src", wpc_home_url + "/" + wpc_plugin_dir_url + "/captcha/captcha.php?comm_id=" + wpc_commpost_ID + '-' + wpc_commparent + '&r=' + Math.random()); }); $(document).on('click', '.wpc_comm_submit', function (){ wpc_submitID=$(this).attr('id'); var uniqueID=wpc_submitID.substring(wpc_submitID.lastIndexOf('-') + 1); wpc_name=$('#wpc_name-' + uniqueID).val(); wpc_email=$('#wpc_email-' + uniqueID).val(); wpc_comment=$('textarea#wpc_comment-' + uniqueID).val(); wpc_captcha=$('#wpc_captcha-' + uniqueID).val(); wpc_comment_post_ID=$('#wpc_comment_post_ID-' + uniqueID).val(); wpc_comment_parent=$('#wpc_comment_parent-' + uniqueID).val(); wpc_form=$('#wpc_comm_form-' + uniqueID); var depth=''; if(isMainFormSubmit(wpc_submitID, wpc_comment_post_ID)){ depth=1; }else{ depth=getCommentDepth($(this).parents('.wpc-comment')); } var submit=true; if(!woodiscuzValidator.checkAll(wpc_form)){ submit=false; $('#wpc_captcha-' + uniqueID).val(''); $("#wpc_captcha_img-" + uniqueID).attr("src", wpc_home_url + "/" + wpc_plugin_dir_url + "/captcha/captcha.php?comm_id=" + wpc_comment_post_ID + '-' + wpc_comment_parent + '&r=' + Math.random()); }else{ $('#wpc_openModalFormAction .close').css('display', 'none'); $('#wpc_openModalFormAction').css('opacity', '1'); $('#wpc_openModalFormAction').css('pointer-events', 'auto'); $('#wpc_openModalFormAction > #wpc_response_info').html(wpc_loading_image); } var notification_type=''; var notification_type_radio=$("input[name='wpc_notification_new_reply-" + uniqueID + "']:checked").length ? $("input[name='wpc_notification_new_reply-" + uniqueID + "']:checked").val():''; if(notification_type_radio.length){ if(notification_type_radio=='wpc_notification_new_reply'){ notification_type='reply'; }} if(submit){ $.ajax({ type: 'POST', url: wpc_ajax_obj.url, data: { name: wpc_name, email: wpc_email, comment: wpc_comment, captcha: wpc_captcha, comment_depth: depth, comment_post_ID: wpc_comment_post_ID, comment_parent: wpc_comment_parent, notification_type: notification_type, action: 'wpc_comms_via_ajax' }}).done(function (response){ $("#wpc_captcha_img-" + uniqueID).attr("src", wpc_home_url + "/" + wpc_plugin_dir_url + "/captcha/captcha.php?comm_id=" + wpc_comment_post_ID + '-' + wpc_comment_parent + '&r=' + Math.random()); var obj=$.parseJSON(response); wpc_new_comment_id=parseInt(obj.wpc_new_comment_id); if(obj.code===-1){ $('#wpc_response_info').html(obj.message); }else if(obj.code===-2){ var html=" "; $('#wpc_response_info').html(html + obj.message); $('#wpc_openModalFormAction .close').css('display', 'block'); $('#wpc_comment-' + uniqueID).val(''); $('.wpc_comm_form textarea').css('height', '46px'); if(wpc_submitID==='wpc_comm-' + wpc_comment_post_ID + '_0'){ $('#wpc-form-footer-' + uniqueID).slideToggle(700); }else{ $('#wpc-secondary-forms-wrapper-' + uniqueID).slideToggle(700); } $.cookie('wpc_author_name', wpc_name); $.cookie('wpc_author_email', wpc_email); $.cookie('wpc_poster', wpc_email, 60 * 60 * 24 * 365 * 10); }else{ $('#wpc_comment-' + uniqueID).val(''); $('.wpc_comm_form textarea').css('height', '46px'); if(wpc_submitID==='wpc_comm-' + wpc_comment_post_ID + '_0'){ $('.wpc-thread-wrapper').prepend(obj.message); $('#wpc-form-footer-' + uniqueID).slideToggle(700); }else{ $('#wpc-secondary-forms-wrapper-' + uniqueID).slideToggle(700); if(obj.is_in_same_container==1){ $('#wpc-secondary-forms-wrapper-' + uniqueID).after(obj.message); }else{ $('#wpc-secondary-forms-wrapper-' + uniqueID).after(obj.message.replace('wpc-reply', 'wpc-reply wpc-no-left-margin')); }} $('#wpc_openModalFormAction').css('opacity', '0'); $('#wpc_openModalFormAction').css('pointer-events', 'none'); if(wpc_name!==''&&wpc_email!==''){ $.cookie('wpc_author_name', wpc_name); $.cookie('wpc_author_email', wpc_email); $('#woopcomm .wpc_name').val(wpc_name); $('#woopcomm .wpc_email').val(wpc_email); } $.cookie('wpc_poster', wpc_email, 60 * 60 * 24 * 365 * 10); if(wpc_new_comment_id!==-1){ notify_on_new_comment(wpc_comment_post_ID, wpc_new_comment_id, wpc_email); }} $('#wpc_captcha-' + uniqueID).val(''); $('.wpc_tooltipster').tooltipster({offsetY: 2,multiple:true}); $('.wpc_comm_form input').css('box-shadow', '0 0 4px -2px #d4d0ba'); $('.wpc_comm_form textarea').css('box-shadow', '0 0 4px -2px #d4d0ba'); if((obj.code==1||obj.code==-2)&&$('form.wpc_main_form').hasClass('wpc-no-comments')){ $.ajax({ type: 'POST', url: wpc_ajax_obj.url, data: { wpc_new_comment_id: wpc_new_comment_id, action: 'woodiscuz_comment_redirect' }}).done(function (redirectResponse){ try { var redirectObj=$.parseJSON(redirectResponse); if(redirectObj.code==1){ setTimeout(function (){ window.location.href=redirectObj.redirect_to; }, 5000) }} catch (e){ }}); }}); }else{ return false; }}); $(document).on('click', '.wpc_vote', function (){ var uniqueID=getUniqueID($(this)); var commentID=getCommentID(uniqueID); var voteType; $('#wpc_openModalFormAction > #wpc_response_info').html(wpc_loading_image); $('#wpc_openModalFormAction .close').css('display', 'block'); $('#wpc_openModalFormAction').css('opacity', '1'); $('#wpc_openModalFormAction').css('pointer-events', 'auto'); if($(this).hasClass('wpc-up')){ voteType=1; }else{ voteType=-1; } $.ajax({ dateType: 'json', type: 'POST', url: wpc_ajax_obj.url, data: { comment_ID: commentID, vote_type: voteType, action: 'wpc_vote_via_ajax' }}).done(function (response){ var obj=$.parseJSON(response); if(obj.code!==-1){ $('#vote-count-' + uniqueID).text(parseInt($('#vote-count-' + uniqueID).text()) + voteType); $('#wpc_openModalFormAction').css('opacity', '0'); $('#wpc_openModalFormAction').css('pointer-events', 'none'); }else{ var html=" "; $('#wpc_response_info').html(html + obj.message); $('#wpc_openModalFormAction .close').css('display', 'block'); }}); }); $(document).on('click', '.wpc-load-more-submit', function (){ $('#wpc_openModalFormAction > #wpc_response_info').html(wpc_loading_image); $('#wpc_openModalFormAction .close').css('display', 'none'); $('#wpc_openModalFormAction').css('opacity', '1'); $('#wpc_openModalFormAction').css('pointer-events', 'auto'); var wpc_comments_offset_value=wpc_comments_offset.val(); var wpc_post_id=getPostID($(this).attr('id')); var wpc_parent_comments_count=parseInt($('#wpc_parent_comments_count').val()); var wpc_parent_per_page=parseInt($('#wpc_parent_per_page').val()); wpc_comments_offset_value=parseInt(wpc_comments_offset_value); wpc_comments_offset_value++; $.ajax({ type: 'POST', url: wpc_ajax_obj.url, data: { comments_offset: wpc_comments_offset_value, wpc_post_id: wpc_post_id, action: 'wpc_load_more_comments' }}).done(function (response){ wpc_comments_offset.val(wpc_comments_offset_value); if(wpc_parent_comments_count <=(wpc_comments_offset_value * wpc_parent_per_page)){ $('.wpc-load-more-submit-wrap').remove(); } $('.wpc-thread-wrapper').html(response); $('#wpc_openModalFormAction').css('opacity', '0'); $('#wpc_openModalFormAction').css('pointer-events', 'none'); $('.wpc_tooltipster').tooltipster({offsetY: 2}); }); }); function getUniqueID(field){ var fieldID=field.attr('id'); var uniqueID=fieldID.substring(fieldID.lastIndexOf('-') + 1); return uniqueID; } function getPostID(uniqueID){ var postID=uniqueID.substring(uniqueID.lastIndexOf('-') + 1); postID=postID.substring(0, postID.lastIndexOf('_')); return postID; } function getCommentID(uniqueID){ var commentID=uniqueID.substring(uniqueID.indexOf('_') + 1); return commentID; } function notify_on_new_comment(post_id, comment_id, email){ $.ajax({ type: 'POST', url: wpc_ajax_obj.url, data: { wpc_post_id: post_id, wpc_comment_id: comment_id, wpc_email: email, action: 'wpc_check_notification_type' }}); } $(document).on('click', '.wpc_editable_comment', function (){ var uniqueID=getUniqueID($(this)); var commentID=getCommentID(uniqueID); $.ajax({ type: 'POST', url: wpc_ajax_obj.url, data: { comment_id: commentID, action: 'wpc_get_editable_comment_content' }}).done(function (response){ try { var obj=$.parseJSON(response); if(obj.code==1){ wpc_comment_text_before_editting=obj.message; var editableTextarea=''; $('#wpc-comm-' + uniqueID + ' > .wpc-comment-right .wpc-comment-text').replaceWith(editableTextarea); document.getElementById('wpc_edit_comment-' + uniqueID).trigger('focus'); $('#wpc_save_edited_comment-' + uniqueID).show(); editableTextarea=''; $('#wpc_editable_comment-' + uniqueID).hide(); $('#wpc_cancel_edit-' + uniqueID).show(); }else{ var html=" "; $('#wpc_openModalFormAction').css('opacity', '1'); $('#wpc_openModalFormAction').css('pointer-events', 'auto'); $('#wpc_openModalFormAction .close').css('display', 'block'); $('#wpc_openModalFormAction > #wpc_response_info').html(html + obj.phrase_message); }} catch (e){ console.log(e); }}); }); $(document).on('click', '.wpc_save_edited_comment', function (){ var uniqueID=getUniqueID($(this)); var commentID=getCommentID(uniqueID); var editableTextarea=$('#wpc-comm-' + uniqueID + ' textarea#wpc_edit_comment-' + uniqueID); var commentContent=editableTextarea.val(); var submit=true; if($.trim(commentContent).length <=0){ submit=false; } if(submit){ $('#wpc_openModalFormAction .close').css('display', 'none'); $('#wpc_openModalFormAction').css('opacity', '1'); $('#wpc_openModalFormAction').css('pointer-events', 'auto'); $('#wpc_openModalFormAction > #wpc_response_info').html(wpc_loading_image); $.ajax({ type: 'POST', url: wpc_ajax_obj.url, data: { comment_id: commentID, comment_content: commentContent, action: 'wpc_save_edited_comment' }}).done(function (response){ try { var obj=$.parseJSON(response); if(obj.code==1){ $('#wpc_openModalFormAction').css('opacity', '0'); $('#wpc_openModalFormAction').css('pointer-events', 'none'); wpc_cancel_or_save(uniqueID, obj.message); }else{ var html=" "; $('#wpc_openModalFormAction').css('opacity', '1'); $('#wpc_openModalFormAction').css('pointer-events', 'auto'); $('#wpc_openModalFormAction .close').css('display', 'block'); $('#wpc_openModalFormAction > #wpc_response_info').html(html + obj.phrase_message); } editableTextarea=''; commentContent=''; } catch (e){ console.log(e); }}); }}); $(document).on('click', '.wpc_cancel_edit', function (){ var uniqueID=getUniqueID($(this)); wpc_cancel_or_save(uniqueID, wpc_comment_text_before_editting); }); function wpc_cancel_or_save(uniqueID, content){ $('#wpc_editable_comment-' + uniqueID).show(); $('#wpc_cancel_edit-' + uniqueID).hide(); $('#wpc_save_edited_comment-' + uniqueID).hide(); var commentContentWrapper='
' + nl2br(content) + '
'; $('#wpc-comm-' + uniqueID + ' #wpc_edit_comment-' + uniqueID).replaceWith(commentContentWrapper); } function nl2br(str, is_xhtml){ var breakTag=(is_xhtml||typeof is_xhtml==='undefined') ? '
':'
'; var string=(str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); return string.replace('

', '
'); } function getCommentDepth(field){ var fieldClasses=field.attr('class'); var classesArray=fieldClasses.split(' '); var depth=''; $.each(classesArray, function (index, value){ ; if('wpc_comment_level'===getParentDepth(value, false)){ depth=getParentDepth(value, true); }}); return parseInt(depth) + 1; } function getParentDepth(depthValue, isNumberPart){ var depth=''; if(isNumberPart){ depth=depthValue.substring(depthValue.indexOf('-') + 1); }else{ depth=depthValue.substring(0, depthValue.indexOf('-')); } return depth; } function isMainFormSubmit(wpc_submitID, wpc_comment_post_ID){ return wpc_submitID==='wpc_comm-' + wpc_comment_post_ID + '_0'; } $('.wpc_tooltipster').tooltipster({offsetY: 2}); }); (function (factory){ if(typeof define==='function'&&define.amd){ define(['jquery'], factory); }else if(typeof exports==='object'){ factory(require('jquery')); }else{ factory(jQuery); }}(function ($){ var pluses=/\+/g; function encode(s){ return config.raw ? s:encodeURIComponent(s); } function decode(s){ return config.raw ? s:decodeURIComponent(s); } function stringifyCookieValue(value){ return encode(config.json ? JSON.stringify(value):String(value)); } function parseCookieValue(s){ if(s.indexOf('"')===0){ s=s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } try { s=decodeURIComponent(s.replace(pluses, ' ')); return config.json ? JSON.parse(s):s; } catch(e){}} function read(s, converter){ var value=config.raw ? s:parseCookieValue(s); return $.isFunction(converter) ? converter(value):value; } var config=$.cookie=function (key, value, options){ if(value!==undefined&&!$.isFunction(value)){ options=$.extend({}, config.defaults, options); if(typeof options.expires==='number'){ var days=options.expires, t=options.expires=new Date(); t.setTime(+t + days * 864e+5); } return (document.cookie=[ encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString():'', options.path ? '; path=' + options.path:'', options.domain ? '; domain=' + options.domain:'', options.secure ? '; secure':'' ].join('')); } var result=key ? undefined:{}; var cookies=document.cookie ? document.cookie.split('; '):[]; for (var i=0, l=cookies.length; i < l; i++){ var parts=cookies[i].split('='); var name=decode(parts.shift()); var cookie=parts.join('='); if(key&&key===name){ result=read(cookie, value); break; } if(!key&&(cookie=read(cookie))!==undefined){ result[name]=cookie; }} return result; }; config.defaults={}; $.removeCookie=function (key, options){ if($.cookie(key)===undefined){ return false; } $.cookie(key, '', $.extend({}, options, { expires: -1 })); return !$.cookie(key); };})); ;(function(e,t,n){function s(t,n){this.bodyOverflowX;this.callbacks={hide:[],show:[]};this.checkInterval=null;this.Content;this.$el=e(t);this.$elProxy;this.elProxyPosition;this.enabled=true;this.options=e.extend({},i,n);this.mouseIsOverProxy=false;this.namespace="tooltipster-"+Math.round(Math.random()*1e5);this.Status="hidden";this.timerHide=null;this.timerShow=null;this.$tooltip;this.options.iconTheme=this.options.iconTheme.replace(".","");this.options.theme=this.options.theme.replace(".","");this._init()}function o(t,n){var r=true;e.each(t,function(e,i){if(typeof n[e]==="undefined"||t[e]!==n[e]){r=false;return false}});return r}function f(){return!a&&u}function l(){var e=n.body||n.documentElement,t=e.style,r="transition";if(typeof t[r]=="string"){return true}v=["Moz","Webkit","Khtml","O","ms"],r=r.charAt(0).toUpperCase()+r.substr(1);for(var i=0;i');t.$elProxy.text(t.options.icon)}else{if(t.options.iconCloning)t.$elProxy=t.options.icon.clone(true);else t.$elProxy=t.options.icon}t.$elProxy.insertAfter(t.$el)}else{t.$elProxy=t.$el}if(t.options.trigger=="hover"){t.$elProxy.on("mouseenter."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=true;t._show()}}).on("mouseleave."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=false}});if(u&&t.options.touchDevices){t.$elProxy.on("touchstart."+t.namespace,function(){t._showNow()})}}else if(t.options.trigger=="click"){t.$elProxy.on("click."+t.namespace,function(){if(!f()||t.options.touchDevices){t._show()}})}}},_show:function(){var e=this;if(e.Status!="shown"&&e.Status!="appearing"){if(e.options.delay){e.timerShow=setTimeout(function(){if(e.options.trigger=="click"||e.options.trigger=="hover"&&e.mouseIsOverProxy){e._showNow()}},e.options.delay)}else e._showNow()}},_showNow:function(n){var r=this;r.options.functionBefore.call(r.$el,r.$el,function(){if(r.enabled&&r.Content!==null){if(n)r.callbacks.show.push(n);r.callbacks.hide=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;if(r.options.onlyOne){e(".tooltipstered").not(r.$el).each(function(t,n){var r=e(n),i=r.data("tooltipster-ns");e.each(i,function(e,t){var n=r.data(t),i=n.status(),s=n.option("autoClose");if(i!=="hidden"&&i!=="disappearing"&&s){n.hide()}})})}var i=function(){r.Status="shown";e.each(r.callbacks.show,function(e,t){t.call(r.$el)});r.callbacks.show=[]};if(r.Status!=="hidden"){var s=0;if(r.Status==="disappearing"){r.Status="appearing";if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-dying").addClass("tooltipster-"+r.options.animation+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.stop().fadeIn(i)}}else if(r.Status==="shown"){i()}}else{r.Status="appearing";var s=r.options.speed;r.bodyOverflowX=e("body").css("overflow-x");e("body").css("overflow-x","hidden");var o="tooltipster-"+r.options.animation,a="-webkit-transition-duration: "+r.options.speed+"ms; -webkit-animation-duration: "+r.options.speed+"ms; -moz-transition-duration: "+r.options.speed+"ms; -moz-animation-duration: "+r.options.speed+"ms; -o-transition-duration: "+r.options.speed+"ms; -o-animation-duration: "+r.options.speed+"ms; -ms-transition-duration: "+r.options.speed+"ms; -ms-animation-duration: "+r.options.speed+"ms; transition-duration: "+r.options.speed+"ms; animation-duration: "+r.options.speed+"ms;",f=r.options.minWidth?"min-width:"+Math.round(r.options.minWidth)+"px;":"",c=r.options.maxWidth?"max-width:"+Math.round(r.options.maxWidth)+"px;":"",h=r.options.interactive?"pointer-events: auto;":"";r.$tooltip=e('
');if(l())r.$tooltip.addClass(o);r._content_insert();r.$tooltip.appendTo("body");r.reposition();r.options.functionReady.call(r.$el,r.$el,r.$tooltip);if(l()){r.$tooltip.addClass(o+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.css("display","none").fadeIn(r.options.speed,i)}r._interval_set();e(t).on("scroll."+r.namespace+" resize."+r.namespace,function(){r.reposition()});if(r.options.autoClose){e("body").off("."+r.namespace);if(r.options.trigger=="hover"){if(u){setTimeout(function(){e("body").on("touchstart."+r.namespace,function(){r.hide()})},0)}if(r.options.interactive){if(u){r.$tooltip.on("touchstart."+r.namespace,function(e){e.stopPropagation()})}var p=null;r.$elProxy.add(r.$tooltip).on("mouseleave."+r.namespace+"-autoClose",function(){clearTimeout(p);p=setTimeout(function(){r.hide()},r.options.interactiveTolerance)}).on("mouseenter."+r.namespace+"-autoClose",function(){clearTimeout(p)})}else{r.$elProxy.on("mouseleave."+r.namespace+"-autoClose",function(){r.hide()})}}else if(r.options.trigger=="click"){setTimeout(function(){e("body").on("click."+r.namespace+" touchstart."+r.namespace,function(){r.hide()})},0);if(r.options.interactive){r.$tooltip.on("click."+r.namespace+" touchstart."+r.namespace,function(e){e.stopPropagation()})}}}}if(r.options.timer>0){r.timerHide=setTimeout(function(){r.timerHide=null;r.hide()},r.options.timer+s)}}})},_interval_set:function(){var t=this;t.checkInterval=setInterval(function(){if(e("body").find(t.$el).length===0||e("body").find(t.$elProxy).length===0||t.Status=="hidden"||e("body").find(t.$tooltip).length===0){if(t.Status=="shown"||t.Status=="appearing")t.hide();t._interval_cancel()}else{if(t.options.positionTracker){var n=t._repositionInfo(t.$elProxy),r=false;if(o(n.dimension,t.elProxyPosition.dimension)){if(t.$elProxy.css("position")==="fixed"){if(o(n.position,t.elProxyPosition.position))r=true}else{if(o(n.offset,t.elProxyPosition.offset))r=true}}if(!r){t.reposition()}}}},200)},_interval_cancel:function(){clearInterval(this.checkInterval);this.checkInterval=null},_content_set:function(e){if(typeof e==="object"&&e!==null&&this.options.contentCloning){e=e.clone(true)}this.Content=e},_content_insert:function(){var e=this,t=this.$tooltip.find(".tooltipster-content");if(typeof e.Content==="string"&&!e.options.contentAsHTML){t.text(e.Content)}else{t.empty().append(e.Content)}},_update:function(e){var t=this;t._content_set(e);if(t.Content!==null){if(t.Status!=="hidden"){t._content_insert();t.reposition();if(t.options.updateAnimation){if(l()){t.$tooltip.css({width:"","-webkit-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-moz-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-o-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-ms-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms",transition:"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms"}).addClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!="hidden"){t.$tooltip.removeClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!=="hidden"){t.$tooltip.css({"-webkit-transition":t.options.speed+"ms","-moz-transition":t.options.speed+"ms","-o-transition":t.options.speed+"ms","-ms-transition":t.options.speed+"ms",transition:t.options.speed+"ms"})}},t.options.speed)}},t.options.speed)}else{t.$tooltip.fadeTo(t.options.speed,.5,function(){if(t.Status!="hidden"){t.$tooltip.fadeTo(t.options.speed,1)}})}}}}else{t.hide()}},_repositionInfo:function(e){return{dimension:{height:e.outerHeight(false),width:e.outerWidth(false)},offset:e.offset(),position:{left:parseInt(e.css("left")),top:parseInt(e.css("top"))}}},hide:function(n){var r=this;if(n)r.callbacks.hide.push(n);r.callbacks.show=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;var i=function(){e.each(r.callbacks.hide,function(e,t){t.call(r.$el)});r.callbacks.hide=[]};if(r.Status=="shown"||r.Status=="appearing"){r.Status="disappearing";var s=function(){r.Status="hidden";if(typeof r.Content=="object"&&r.Content!==null){r.Content.detach()}r.$tooltip.remove();r.$tooltip=null;e(t).off("."+r.namespace);e("body").off("."+r.namespace).css("overflow-x",r.bodyOverflowX);e("body").off("."+r.namespace);r.$elProxy.off("."+r.namespace+"-autoClose");r.options.functionAfter.call(r.$el,r.$el);i()};if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-"+r.options.animation+"-show").addClass("tooltipster-dying");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(s)}else{r.$tooltip.stop().fadeOut(r.options.speed,s)}}else if(r.Status=="hidden"){i()}return r},show:function(e){this._showNow(e);return this},update:function(e){return this.content(e)},content:function(e){if(typeof e==="undefined"){return this.Content}else{this._update(e);return this}},reposition:function(){var n=this;if(e("body").find(n.$tooltip).length!==0){n.$tooltip.css("width","");n.elProxyPosition=n._repositionInfo(n.$elProxy);var r=null,i=e(t).width(),s=n.elProxyPosition,o=n.$tooltip.outerWidth(false),u=n.$tooltip.innerWidth()+1,a=n.$tooltip.outerHeight(false);if(n.$elProxy.is("area")){var f=n.$elProxy.attr("shape"),l=n.$elProxy.parent().attr("name"),c=e('img[usemap="#'+l+'"]'),h=c.offset().left,p=c.offset().top,d=n.$elProxy.attr("coords")!==undefined?n.$elProxy.attr("coords").split(","):undefined;if(f=="circle"){var v=parseInt(d[0]),m=parseInt(d[1]),g=parseInt(d[2]);s.dimension.height=g*2;s.dimension.width=g*2;s.offset.top=p+m-g;s.offset.left=h+v-g}else if(f=="rect"){var v=parseInt(d[0]),m=parseInt(d[1]),y=parseInt(d[2]),b=parseInt(d[3]);s.dimension.height=b-m;s.dimension.width=y-v;s.offset.top=p+m;s.offset.left=h+v}else if(f=="poly"){var w=[],E=[],S=0,x=0,T=0,N=0,C="even";for(var k=0;kT){T=L;if(k===0){S=T}}if(LN){N=L;if(k==1){x=N}}if(Li){r=A-(i+n-o);A=i+n-o}}function B(n,r){if(s.offset.top-e(t).scrollTop()-a-_-12<0&&r.indexOf("top")>-1){P=n}if(s.offset.top+s.dimension.height+a+12+_>e(t).scrollTop()+e(t).height()&&r.indexOf("bottom")>-1){P=n;M=s.offset.top-a-_-12}}if(P=="top"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left+D-j/2;M=s.offset.top-a-_-12;H();B("bottom","top")}if(P=="top-left"){A=s.offset.left+D;M=s.offset.top-a-_-12;H();B("bottom-left","top-left")}if(P=="top-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top-a-_-12;H();B("bottom-right","top-right")}if(P=="bottom"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left-j/2+D;M=s.offset.top+s.dimension.height+_+12;H();B("top","bottom")}if(P=="bottom-left"){A=s.offset.left+D;M=s.offset.top+s.dimension.height+_+12;H();B("top-left","bottom-left")}if(P=="bottom-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top+s.dimension.height+_+12;H();B("top-right","bottom-right")}if(P=="left"){A=s.offset.left-D-o-12;O=s.offset.left+D+s.dimension.width+12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A<0&&O+o>i){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=o+A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);A=s.offset.left-D-q-12-I;F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A<0){A=s.offset.left+D+s.dimension.width+12;r="left"}}if(P=="right"){A=s.offset.left+D+s.dimension.width+12;O=s.offset.left-D-o-12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A+o>i&&O<0){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=i-A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A+o>i){A=s.offset.left-D-o-12;r="right"}}if(n.options.arrow){var R="tooltipster-arrow-"+P;if(n.options.arrowColor.length<1){var U=n.$tooltip.css("background-color")}else{var U=n.options.arrowColor}if(!r){r=""}else if(r=="left"){R="tooltipster-arrow-right";r=""}else if(r=="right"){R="tooltipster-arrow-left";r=""}else{r="left:"+Math.round(r)+"px;"}if(P=="top"||P=="top-left"||P=="top-right"){var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}else if(P=="bottom"||P=="bottom-left"||P=="bottom-right"){var z=parseFloat(n.$tooltip.css("border-top-width")),W=n.$tooltip.css("border-top-color")}else if(P=="left"){var z=parseFloat(n.$tooltip.css("border-right-width")),W=n.$tooltip.css("border-right-color")}else if(P=="right"){var z=parseFloat(n.$tooltip.css("border-left-width")),W=n.$tooltip.css("border-left-color")}else{var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}if(z>1){z++}var X="";if(z!==0){var V="",J="border-color: "+W+";";if(R.indexOf("bottom")!==-1){V="margin-top: -"+Math.round(z)+"px;"}else if(R.indexOf("top")!==-1){V="margin-bottom: -"+Math.round(z)+"px;"}else if(R.indexOf("left")!==-1){V="margin-right: -"+Math.round(z)+"px;"}else if(R.indexOf("right")!==-1){V="margin-left: -"+Math.round(z)+"px;"}X=''}n.$tooltip.find(".tooltipster-arrow").remove();var K='
'+X+'
';n.$tooltip.append(K)}n.$tooltip.css({top:Math.round(M)+"px",left:Math.round(A)+"px"})}return n},enable:function(){this.enabled=true;return this},disable:function(){this.hide();this.enabled=false;return this},destroy:function(){var t=this;t.hide();if(t.$el[0]!==t.$elProxy[0])t.$elProxy.remove();t.$el.removeData(t.namespace).off("."+t.namespace);var n=t.$el.data("tooltipster-ns");if(n.length===1){var r=typeof t.Content==="string"?t.Content:e("
").append(t.Content).html();t.$el.removeClass("tooltipstered").attr("title",r).removeData(t.namespace).removeData("tooltipster-ns").off("."+t.namespace)}else{n=e.grep(n,function(e,n){return e!==t.namespace});t.$el.data("tooltipster-ns",n)}return t},elementIcon:function(){return this.$el[0]!==this.$elProxy[0]?this.$elProxy[0]:undefined},elementTooltip:function(){return this.$tooltip?this.$tooltip[0]:undefined},option:function(e,t){if(typeof t=="undefined")return this.options[e];else{this.options[e]=t;return this}},status:function(){return this.Status}};e.fn[r]=function(){var t=arguments;if(this.length===0){if(typeof t[0]==="string"){var n=true;switch(t[0]){case"setDefaults":e.extend(i,t[1]);break;default:n=false;break}if(n)return true;else return this}else{return this}}else{if(typeof t[0]==="string"){var r="#*$~&";this.each(function(){var n=e(this).data("tooltipster-ns"),i=n?e(this).data(n[0]):null;if(i){if(typeof i[t[0]]==="function"){var s=i[t[0]](t[1],t[2])}else{throw new Error('Unknown method .tooltipster("'+t[0]+'")')}if(s!==i){r=s;return false}}else{throw new Error("You called Tooltipster's \""+t[0]+'" method on an uninitialized element')}});return r!=="#*$~&"?r:this}else{var o=[],u=t[0]&&typeof t[0].multiple!=="undefined",a=u&&t[0].multiple||!u&&i.multiple,f=t[0]&&typeof t[0].debug!=="undefined",l=f&&t[0].debug||!f&&i.debug;this.each(function(){var n=false,r=e(this).data("tooltipster-ns"),i=null;if(!r){n=true}else if(a){n=true}else if(l){console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.')}if(n){i=new s(this,t[0]);if(!r)r=[];r.push(i.namespace);e(this).data("tooltipster-ns",r);e(this).data(i.namespace,i)}o.push(i)});if(a)return o;else return this}}};var u=!!("ontouchstart"in t);var a=false;e("body").one("mousemove",function(){a=true})})(jQuery,window,document); jQuery.fn.autoGrow=function(){return this.each(function(){var createMirror=function(textarea){jQuery(textarea).after('
');return jQuery(textarea).next(".autogrow-textarea-mirror")[0]};var sendContentToMirror=function(textarea){mirror.innerHTML=String(textarea.value).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/\n/g,"
")+".
.";if(jQuery(textarea).height()!=jQuery(mirror).height())jQuery(textarea).height(jQuery(mirror).height())}; var growTextarea=function(){sendContentToMirror(this)};var mirror=createMirror(this);mirror.style.display="none";mirror.style.wordWrap="break-word";mirror.style.padding=jQuery(this).css("padding");mirror.style.width=jQuery(this).css("width");mirror.style.fontFamily=jQuery(this).css("font-family");mirror.style.fontSize=jQuery(this).css("font-size");mirror.style.lineHeight=jQuery(this).css("line-height");this.style.overflow="hidden";this.style.minHeight=this.rows+"em";this.onkeydown=growTextarea;sendContentToMirror(this)})}; (function ($){ 'use strict'; $(function (){ toggleCalculator(); $(document).on('keyup', '.iptCep', function (e){ jQuery('.observation-shipping-free').hide(); resetarTabela(); if($(this).val().length===9){ if($(e.target).is('a#cfpp_credits')){ return; } var url=$('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_endpoint_url').val(); var cep=$('.iptCep').val(); var id_produto=$('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #id_produto').val(); var errors=[]; if(errors.length > 0){ var row=''; row='Ocorreu um erro ao obter informações sobre o valor do frete'; errors.map(item=> { row +=`${item}`; }); $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto .resultado-frete table tbody').append(row); esconderLoader(); exibirTabela(); return false; } let inpCEP=$(this); inpCEP.attr('disabled', 'disabled'); exibirLoader(); esconderTabela(); resetarTabela(); let qty=1; let inpQty=$('.quantity .qty:visible').val(); if(typeof inpQty!='undefined'){ qty=inpQty; } $.ajax({ url: url, type: "POST", data: { 'action': 'cotation_product_page', 'data': { 'cep_origem': cep, 'id_produto': id_produto, 'quantity': qty }}, error: function (jqXHR, exception){ inpCEP.removeAttr('disabled'); inpCEP.val(''); alert(jqXHR.responseJSON.error); esconderLoader(); esconderTabela(); resetarTabela(); return false; }, success: function (response){ $('#destiny-shipping-mehor-envio').text('Frete para ' + response.data.destination); var row=''; let data=response.data.quotations; data.map(item=> { if(item.observations&&item.observations!=='Frete Grátis'){ jQuery('.observation-shipping-free').show(); jQuery('.observation-shipping-free').html(item.observations); } let name=item.name if(!item.delivery_time){ item.delivery_time=''; } row +=`${name} ${item.delivery_time}: ${item.price}`; }); if(row==''){ row='Desculpe, o cálculo de frete para este produto só está disponível no Carrinho, por favor, prossiga com a compra normalmente.'; } $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto .resultado-frete table tbody').append(row); esconderLoader(); exibirTabela(); inpCEP.removeAttr('disabled'); inpCEP.val(''); }}); }}) function exibirLoader(){ $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calcular-frete').css('display', 'none'); $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calcular-frete-loader').css('display', 'flex'); } function esconderLoader(){ $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calcular-frete').css('display', 'inline-block'); $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calcular-frete-loader').css('display', 'none'); } function exibirTabela(){ $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto .resultado-frete').show(); } function esconderTabela(){ $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto .resultado-frete').hide(); } function resetarTabela(){ $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto .resultado-frete table tbody').html(''); $('#destiny-shipping-mehor-envio').text(''); } $(".single_variation_wrap").on("show_variation", function (event, variation){ resetarTabela(); esconderTabela(); $('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_preco').val(variation.display_price.toFixed(2)); }); }); })(jQuery); (function (jQuery){ 'use strict'; jQuery(function (){ jQuery(document).ready(function (){ toggleCalculator(); setProduct(); if(!jQuery('.variations_form')){ return; } let variations=jQuery('.variations_form').data('product_variations'); updateVariation(variations); jQuery('.variations select').change(function (){ setProduct(); updateVariation(variations); }); }) }); function setProduct(){ setTimeout(function(){ let variantion_id=jQuery('.variation_id').val(); let product_id=jQuery('.cart').data('product_id'); let selected_product=variantion_id; if(variantion_id==0){ selected_product=product_id; } if(typeof product_id!="undefined"&&typeof variantion_id!="undefined") jQuery('#id_produto').val(selected_product) }, 200); } function updateVariation(variations){ let attribbutes=new Array(); if(jQuery('.variations select').length==0){ return; } jQuery('.variations select').each(function (){ let key=jQuery(this).attr('data-attribute_name'); let value=this.value; if(value==""){ return; } attribbutes.push({ 'key': key, 'value': value }); }); if(typeof attribbutes=='undefined'||attribbutes.length==0){ resetFormData(); return; } let selected=0; if(jQuery('.variations select').length==attribbutes.length){ variations.map(function (variant, index){ attribbutes.map(function (attr){ if(variant.attributes[attr.key]==attr.value){ selected=index; }}); }); } if(typeof selected=='number'){ setFormData(variations[selected]) }} function setFormData(variation){ if(!variation.dimensions.width || !variation.dimensions.height || !variation.dimensions.length || variation.dimensions.width==0 || variation.dimensions.height==0 || variation.dimensions.length==0){ resetFormData(); return; } jQuery('#calculo_frete_produto_altura').val(variation.dimensions.height) jQuery('#calculo_frete_produto_largura').val(variation.dimensions.width) jQuery('#calculo_frete_produto_comprimento').val(variation.dimensions.length) jQuery('#calculo_frete_produto_peso').val(variation.weight) toggleCalculator(); } function resetFormData(){ jQuery('#id_produto').val(null) jQuery('#calculo_frete_produto_altura').val(null) jQuery('#calculo_frete_produto_largura').val(null) jQuery('#calculo_frete_produto_comprimento').val(null) jQuery('#calculo_frete_produto_peso').val(null) toggleCalculator(); }})(jQuery); function toggleCalculator(){ let widthProduct=document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_altura'); if(!widthProduct){ return; } let dimensions=getDimension(); if(!dimensions.width || !dimensions.heigth || !dimensions.length || !dimensions.weight || dimensions.width==0 || dimensions.heigth==0 || dimensions.length==0 || dimensions.weight==0 ){ document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto').style.display='none'; return; } document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto').style.display='block'; } function getDimension(){ let dimensions={ 'heigth': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_altura').value, 'width': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_largura').value, 'length': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_comprimento').value, 'weight': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_peso').value } return dimensions; } function mascara(t, mask){ var i=t.value.length; var carac=mask.substring(i, i+1); var prox_char=mask.substring(i+1, i+2); if(i==0&&carac!='#'){ insereCaracter(t, carac); if(prox_char!='#')insereCaracter(t, prox_char); } else if(carac!='#'){ insereCaracter(t, carac); if(prox_char!='#')insereCaracter(t, prox_char); } function insereCaracter(t, char){ t.value +=char; }} function validateNumber(event){ var key=window.event ? event.keyCode:event.which; if(event.keyCode===8||event.keyCode===46){ return true; }else if(key < 48||key > 57){ return false; }else{ return true; }}; if(typeof jQuery==='undefined'){ throw new Error('Bootstrap\'s JavaScript requires jQuery') } +function ($){ 'use strict'; var version=$.fn.jquery.split(' ')[0].split('.') if((version[0] < 2&&version[1] < 9)||(version[0]==1&&version[1]==9&&version[2] < 1)){ throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher') }}(jQuery); +function ($){ 'use strict'; function transitionEnd(){ var el=document.createElement('bootstrap') var transEndEventNames={ WebkitTransition:'webkitTransitionEnd', MozTransition:'transitionend', OTransition:'oTransitionEnd otransitionend', transition:'transitionend' } for (var name in transEndEventNames){ if(el.style[name]!==undefined){ return { end: transEndEventNames[name] }} } return false } $.fn.emulateTransitionEnd=function (duration){ var called=false var $el=this $(this).one('bsTransitionEnd', function (){ called=true }) var callback=function (){ if(!called) $($el).trigger($.support.transition.end) } setTimeout(callback, duration) return this } $(function (){ $.support.transition=transitionEnd() if(!$.support.transition) return $.event.special.bsTransitionEnd={ bindType: $.support.transition.end, delegateType: $.support.transition.end, handle: function (e){ if($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) }} }) }(jQuery); +function ($){ 'use strict'; var dismiss='[data-dismiss="alert"]' var Alert=function (el){ $(el).on('click', dismiss, this.close) } Alert.VERSION='3.3.4' Alert.TRANSITION_DURATION=150 Alert.prototype.close=function (e){ var $this=$(this) var selector=$this.attr('data-target') if(!selector){ selector=$this.attr('href') selector=selector&&selector.replace(/.*(?=#[^\s]*$)/, '') } var $parent=$(selector) if(e) e.preventDefault() if(!$parent.length){ $parent=$this.closest('.alert') } $parent.trigger(e=$.Event('close.bs.alert')) if(e.isDefaultPrevented()) return $parent.removeClass('in') function removeElement(){ $parent.detach().trigger('closed.bs.alert').remove() } $.support.transition&&$parent.hasClass('fade') ? $parent .one('bsTransitionEnd', removeElement) .emulateTransitionEnd(Alert.TRANSITION_DURATION) : removeElement() } function Plugin(option){ return this.each(function (){ var $this=$(this) var data=$this.data('bs.alert') if(!data) $this.data('bs.alert', (data=new Alert(this))) if(typeof option=='string') data[option].call($this) }) } var old=$.fn.alert $.fn.alert=Plugin $.fn.alert.Constructor=Alert $.fn.alert.noConflict=function (){ $.fn.alert=old return this } $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) }(jQuery); +function ($){ 'use strict'; var Button=function (element, options){ this.$element=$(element) this.options=$.extend({}, Button.DEFAULTS, options) this.isLoading=false } Button.VERSION='3.3.4' Button.DEFAULTS={ loadingText: 'loading...' } Button.prototype.setState=function (state){ var d='disabled' var $el=this.$element var val=$el.is('input') ? 'val':'html' var data=$el.data() state=state + 'Text' if(data.resetText==null) $el.data('resetText', $el[val]()) setTimeout($.proxy(function (){ $el[val](data[state]==null ? this.options[state]:data[state]) if(state=='loadingText'){ this.isLoading=true $el.addClass(d).attr(d, d) }else if(this.isLoading){ this.isLoading=false $el.removeClass(d).removeAttr(d) }}, this), 0) } Button.prototype.toggle=function (){ var changed=true var $parent=this.$element.closest('[data-toggle="buttons"]') if($parent.length){ var $input=this.$element.find('input') if($input.prop('type')=='radio'){ if($input.prop('checked')&&this.$element.hasClass('active')) changed=false else $parent.find('.active').removeClass('active') } if(changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') }else{ this.$element.attr('aria-pressed', !this.$element.hasClass('active')) } if(changed) this.$element.toggleClass('active') } function Plugin(option){ return this.each(function (){ var $this=$(this) var data=$this.data('bs.button') var options=typeof option=='object'&&option if(!data) $this.data('bs.button', (data=new Button(this, options))) if(option=='toggle') data.toggle() else if(option) data.setState(option) }) } var old=$.fn.button $.fn.button=Plugin $.fn.button.Constructor=Button $.fn.button.noConflict=function (){ $.fn.button=old return this } $(document) .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e){ var $btn=$(e.target) if(!$btn.hasClass('btn')) $btn=$btn.closest('.btn') Plugin.call($btn, 'toggle') e.preventDefault() }) .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e){ $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type)) }) }(jQuery); +function ($){ 'use strict'; var Carousel=function (element, options){ this.$element=$(element) this.$indicators=this.$element.find('.carousel-indicators') this.options=options this.paused=null this.sliding=null this.interval=null this.$active=null this.$items=null this.options.keyboard&&this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this)) this.options.pause=='hover'&&!('ontouchstart' in document.documentElement)&&this.$element .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) } Carousel.VERSION='3.3.4' Carousel.TRANSITION_DURATION=600 Carousel.DEFAULTS={ interval: 5000, pause: 'hover', wrap: true, keyboard: true } Carousel.prototype.keydown=function (e){ if(/input|textarea/i.test(e.target.tagName)) return switch (e.which){ case 37: this.prev(); break case 39: this.next(); break default: return } e.preventDefault() } Carousel.prototype.cycle=function (e){ e||(this.paused=false) this.interval&&clearInterval(this.interval) this.options.interval && !this.paused && (this.interval=setInterval($.proxy(this.next, this), this.options.interval)) return this } Carousel.prototype.getItemIndex=function (item){ this.$items=item.parent().children('.item') return this.$items.index(item||this.$active) } Carousel.prototype.getItemForDirection=function (direction, active){ var activeIndex=this.getItemIndex(active) var willWrap=(direction=='prev'&&activeIndex===0) || (direction=='next'&&activeIndex==(this.$items.length - 1)) if(willWrap&&!this.options.wrap) return active var delta=direction=='prev' ? -1:1 var itemIndex=(activeIndex + delta) % this.$items.length return this.$items.eq(itemIndex) } Carousel.prototype.to=function (pos){ var that=this var activeIndex=this.getItemIndex(this.$active=this.$element.find('.item.active')) if(pos > (this.$items.length - 1)||pos < 0) return if(this.sliding) return this.$element.one('slid.bs.carousel', function (){ that.to(pos) }) if(activeIndex==pos) return this.pause().cycle() return this.slide(pos > activeIndex ? 'next':'prev', this.$items.eq(pos)) } Carousel.prototype.pause=function (e){ e||(this.paused=true) if(this.$element.find('.next, .prev').length&&$.support.transition){ this.$element.trigger($.support.transition.end) this.cycle(true) } this.interval=clearInterval(this.interval) return this } Carousel.prototype.next=function (){ if(this.sliding) return return this.slide('next') } Carousel.prototype.prev=function (){ if(this.sliding) return return this.slide('prev') } Carousel.prototype.slide=function (type, next){ var $active=this.$element.find('.item.active') var $next=next||this.getItemForDirection(type, $active) var isCycling=this.interval var direction=type=='next' ? 'left':'right' var that=this if($next.hasClass('active')) return (this.sliding=false) var relatedTarget=$next[0] var slideEvent=$.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) this.$element.trigger(slideEvent) if(slideEvent.isDefaultPrevented()) return this.sliding=true isCycling&&this.pause() if(this.$indicators.length){ this.$indicators.find('.active').removeClass('active') var $nextIndicator=$(this.$indicators.children()[this.getItemIndex($next)]) $nextIndicator&&$nextIndicator.addClass('active') } var slidEvent=$.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) if($.support.transition&&this.$element.hasClass('slide')){ $next.addClass(type) $next[0].offsetWidth $active.addClass(direction) $next.addClass(direction) $active .one('bsTransitionEnd', function (){ $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) that.sliding=false setTimeout(function (){ that.$element.trigger(slidEvent) }, 0) }) .emulateTransitionEnd(Carousel.TRANSITION_DURATION) }else{ $active.removeClass('active') $next.addClass('active') this.sliding=false this.$element.trigger(slidEvent) } isCycling&&this.cycle() return this } function Plugin(option){ return this.each(function (){ var $this=$(this) var data=$this.data('bs.carousel') var options=$.extend({}, Carousel.DEFAULTS, $this.data(), typeof option=='object'&&option) var action=typeof option=='string' ? option:options.slide if(!data) $this.data('bs.carousel', (data=new Carousel(this, options))) if(typeof option=='number') data.to(option) else if(action) data[action]() else if(options.interval) data.pause().cycle() }) } var old=$.fn.carousel $.fn.carousel=Plugin $.fn.carousel.Constructor=Carousel $.fn.carousel.noConflict=function (){ $.fn.carousel=old return this } var clickHandler=function (e){ var href var $this=$(this) var $target=$($this.attr('data-target')||(href=$this.attr('href'))&&href.replace(/.*(?=#[^\s]+$)/, '')) if(!$target.hasClass('carousel')) return var options=$.extend({}, $target.data(), $this.data()) var slideIndex=$this.attr('data-slide-to') if(slideIndex) options.interval=false Plugin.call($target, options) if(slideIndex){ $target.data('bs.carousel').to(slideIndex) } e.preventDefault() } $(document) .on('click.bs.carousel.data-api', '[data-slide]', clickHandler) .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler) $(window).on('load', function (){ $('[data-ride="carousel"]').each(function (){ var $carousel=$(this) Plugin.call($carousel, $carousel.data()) }) }) }(jQuery); +function ($){ 'use strict'; var Collapse=function (element, options){ this.$element=$(element) this.options=$.extend({}, Collapse.DEFAULTS, options) this.$trigger=$('[data-toggle="collapse"][href="#' + element.id + '"],' + '[data-toggle="collapse"][data-target="#' + element.id + '"]') this.transitioning=null if(this.options.parent){ this.$parent=this.getParent() }else{ this.addAriaAndCollapsedClass(this.$element, this.$trigger) } if(this.options.toggle) this.toggle() } Collapse.VERSION='3.3.4' Collapse.TRANSITION_DURATION=350 Collapse.DEFAULTS={ toggle: true } Collapse.prototype.dimension=function (){ var hasWidth=this.$element.hasClass('width') return hasWidth ? 'width':'height' } Collapse.prototype.show=function (){ if(this.transitioning||this.$element.hasClass('in')) return var activesData var actives=this.$parent&&this.$parent.children('.panel').children('.in, .collapsing') if(actives&&actives.length){ activesData=actives.data('bs.collapse') if(activesData&&activesData.transitioning) return } var startEvent=$.Event('show.bs.collapse') this.$element.trigger(startEvent) if(startEvent.isDefaultPrevented()) return if(actives&&actives.length){ Plugin.call(actives, 'hide') activesData||actives.data('bs.collapse', null) } var dimension=this.dimension() this.$element .removeClass('collapse') .addClass('collapsing')[dimension](0) .attr('aria-expanded', true) this.$trigger .removeClass('collapsed') .attr('aria-expanded', true) this.transitioning=1 var complete=function (){ this.$element .removeClass('collapsing') .addClass('collapse in')[dimension]('') this.transitioning=0 this.$element .trigger('shown.bs.collapse') } if(!$.support.transition) return complete.call(this) var scrollSize=$.camelCase(['scroll', dimension].join('-')) this.$element .one('bsTransitionEnd', $.proxy(complete, this)) .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) } Collapse.prototype.hide=function (){ if(this.transitioning||!this.$element.hasClass('in')) return var startEvent=$.Event('hide.bs.collapse') this.$element.trigger(startEvent) if(startEvent.isDefaultPrevented()) return var dimension=this.dimension() this.$element[dimension](this.$element[dimension]())[0].offsetHeight this.$element .addClass('collapsing') .removeClass('collapse in') .attr('aria-expanded', false) this.$trigger .addClass('collapsed') .attr('aria-expanded', false) this.transitioning=1 var complete=function (){ this.transitioning=0 this.$element .removeClass('collapsing') .addClass('collapse') .trigger('hidden.bs.collapse') } if(!$.support.transition) return complete.call(this) this.$element [dimension](0) .one('bsTransitionEnd', $.proxy(complete, this)) .emulateTransitionEnd(Collapse.TRANSITION_DURATION) } Collapse.prototype.toggle=function (){ this[this.$element.hasClass('in') ? 'hide':'show']() } Collapse.prototype.getParent=function (){ return $(this.options.parent) .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]') .each($.proxy(function (i, element){ var $element=$(element) this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element) }, this)) .end() } Collapse.prototype.addAriaAndCollapsedClass=function ($element, $trigger){ var isOpen=$element.hasClass('in') $element.attr('aria-expanded', isOpen) $trigger .toggleClass('collapsed', !isOpen) .attr('aria-expanded', isOpen) } function getTargetFromTrigger($trigger){ var href var target=$trigger.attr('data-target') || (href=$trigger.attr('href'))&&href.replace(/.*(?=#[^\s]+$)/, '') return $(target) } function Plugin(option){ return this.each(function (){ var $this=$(this) var data=$this.data('bs.collapse') var options=$.extend({}, Collapse.DEFAULTS, $this.data(), typeof option=='object'&&option) if(!data&&options.toggle&&/show|hide/.test(option)) options.toggle=false if(!data) $this.data('bs.collapse', (data=new Collapse(this, options))) if(typeof option=='string') data[option]() }) } var old=$.fn.collapse $.fn.collapse=Plugin $.fn.collapse.Constructor=Collapse $.fn.collapse.noConflict=function (){ $.fn.collapse=old return this } $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e){ var $this=$(this) if(!$this.attr('data-target')) e.preventDefault() var $target=getTargetFromTrigger($this) var data=$target.data('bs.collapse') var option=data ? 'toggle':$this.data() Plugin.call($target, option) }) }(jQuery); +function ($){ 'use strict'; var backdrop='.dropdown-backdrop' var toggle='[data-toggle="dropdown"]' var Dropdown=function (element){ $(element).on('click.bs.dropdown', this.toggle) } Dropdown.VERSION='3.3.4' Dropdown.prototype.toggle=function (e){ var $this=$(this) if($this.is('.disabled, :disabled')) return var $parent=getParent($this) var isActive=$parent.hasClass('open') clearMenus() if(!isActive){ if('ontouchstart' in document.documentElement&&!$parent.closest('.navbar-nav').length){ $('